<?php session_start();
if(isset($_SESSION['user_id'])):
	$user_id=$_SESSION['user_id'];
	$user_email=$_SESSION['user_email'];
	$nickname=$_SESSION['nickname'];
endif;
if(isset($_GET['logout']) && $_GET['logout']==1):
	
endif;
require_once("php/curl.php");
$stats = json_decode(api("stats/","GET",null),true);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>spork!</title>
<script type="text/javascript" src="scripts/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="scripts/api.js"></script>
<script type="text/javascript" src="scripts/scripts.js"></script>
<link href="style/main.css" rel="stylesheet" type="text/css" />
<style>
	#stats{
		background-color: #fff;
		padding: 20px;
		margin-top: 50px;
	}
	
	#stats div:first-child, #stats div:nth-child(2){
		border-right: 1px #aaaaaa dotted;	
	}
	
	.box{
		display: -webkit-box; 
		display: -moz-box; 
		display: box; 
		box-orient: horizontal;
	}
	
	.box h1{ 
		margin: 0;
		color: #999;
		text-shadow:#fff 0px 1px 0, #000 0 -1px 0;
	}
	
	.flexbox1, .flexbox2, .flexbox3{
		text-align: center;	
	}
	
	.flexbox1{
		-webkit-box-flex: 1; 
		-moz-box-flex: 1; 
		box-flex: 1; 	
	}
	
	.flexbox2{
		-webkit-box-flex: 2; 
		-moz-box-flex: 2; 
		box-flex: 2; 	
	}
	
	.vert-box{
		display: -webkit-box; 
		display: -moz-box; 
		display: box; 
		box-orient: vertical;
	}
</style>
<script>
	$(document).ready(function($){
		size_labels();
	});
</script>
</head>

<body>
<div id="container">
<?php include("nav.php");?>
	<div id="center">
		<img src="images/logo/250x250/logo-red.png" class="spork" align="middle" alt="spork!" title="spork!" />
<?php
if(!$user_id):
?>
        <form id="forgot" action="signup.php" method="post">
        	<h4>New to spork!?</h4>
            <input class="attention" type="submit" value="Sign up for a free account now." />
        	<div class="callback_msg"><?php if(isset($_GET['signup'])): echo "Sign up success!  Please login to continue."; endif;?></div>
            <h4>Forgot your password?</h4> 
            <span id="question-section">

            <label for="email">Your email </label><input type="text" name="email" />
            <br />
            <input type="button" value="Submit" onClick="getForgotQuestion()" />
            </span>
            
            <span id="answer-section" style="display:none">
            <label id="question" for="question"></label><input type="text" name="pfa" />
            <br />
            <label for="new_password">New Password</label><input type="password" name="new_password" />
            <br />
            <input type="button" value="Submit" onClick="checkForgotAnswer()" />
            </span>
    	</form><!--login-->
<?php
else:
?>
		<input type="button" value="Logout" onClick="logout()" />
<?php
endif;
?>

<?php
$stats = json_decode(api("stats/","GET",null),true);
?>
		<div id="stats" class="box round shadow">
            <div id="total_user_stats" class="flexbox1">
                <h1><?php echo $stats['total_users'];?></h1>
                users sharing recipes
            </div>
            <div id="total_recipe_stats" class="flexbox1">
                <h1><?php echo $stats['recipes_this_month'];?></h1>
                recipes uploaded this month
            </div>
            <div id="recipe_stats" class="flexbox1">
                <h1><?php echo $stats['tried_today'];?></h1>
                new dish<?php if($stats['tried_today']!=1):echo "es"; endif;?> tried today 
            </div>
        </div><!--stats-->


	</div><!--login or signup-->
    
</div><!--container-->
<script>
$("#forgot input[name=email]:first").focus();
random_logo("img.spork:first");
submitOnEnter("#question-section input",getForgotQuestion);
submitOnEnter("#answer-section input",checkForgotAnswer);
</script>

</body>
</html>